package zsc.ruanc.practicaltraining.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import zsc.ruanc.practicaltraining.mapper.AuthorityMapper;
import zsc.ruanc.practicaltraining.mapper.UrlMapper;
import zsc.ruanc.practicaltraining.model.domain.TAuthority;
import zsc.ruanc.practicaltraining.model.domain.TUrl;
import zsc.ruanc.practicaltraining.service.AuthorityService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class AuthorityServiceImpl implements AuthorityService {

    @Autowired
    private AuthorityMapper authorityMapper;

    @Autowired
    private UrlMapper urlMapper;

    // 返回所有的角色
    @Override
    public List<TAuthority> role() {
        return authorityMapper.listAuthority();
    }


    // 返回控制的url
    @Override
    public Map url(int cur, int size) {
        PageHelper.startPage(cur, size);
        PageInfo<TUrl> info = new PageInfo<>(this.urlMapper.selectAll());
        Map map = new HashMap();
        map.put("total", info.getTotal());
        map.put("list", info.getList());
        return map;
    }
}
